﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJERP.BLL;

namespace FJERP
{
    public partial class Blitem_Show : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StockLoad(1);
            }
        }
        protected void StockLoad(int PageIndex)
        {
            BlitemBLL bll = new BlitemBLL();
            int PageSize=4;
            int PageCount;
            this.Repeater1.DataSource = bll.Stock_Show(PageIndex, PageSize,out PageCount);
            this.Repeater1.DataBind();
            this.AspNetPager1.PageSize = PageSize;
            this.AspNetPager1.RecordCount = PageCount;
            this.Label1.Text = PageCount.ToString();
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string eName = e.CommandName;
            string Bid = e.CommandArgument.ToString();
            switch (eName)
            {

                case "Upt":
                    Response.Redirect("BlitemPandian.html?Stock_Id=" + Bid);
                    break;
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            if (this.Supplier_Name.Value == null || this.Supplier_Name.Value == "")
            {
                StockLoad(this.AspNetPager1.CurrentPageIndex);
            }
            else
            {
                SelectStock();
            }
        }
        protected void SelectStock()
        {
            BlitemBLL bll = new BlitemBLL();
            int PageSize = 4;
            int PageCount;
            this.Repeater1.DataSource = bll.SelectStoce(this.AspNetPager1.CurrentPageIndex, PageSize, out PageCount, this.Supplier_Name.Value);
            this.Repeater1.DataBind();
            this.AspNetPager1.PageSize = PageSize;
            this.AspNetPager1.RecordCount = PageCount;
            this.Label1.Text = PageCount.ToString();
        }
        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            SelectStock();
        }
    }
}